package com.demandbreakdown.xiyun;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;

@SpringBootApplication
@MapperScan("com.demandbreakdown.xiyun.mapper")
public class XiyunApplication {

    public static void main(String[] args) {
        SpringApplication.run(XiyunApplication.class, args);
    }

    @Bean
    public ApplicationRunner appStartupLogger(Environment environment) {
        return args -> {
            Logger log = LoggerFactory.getLogger(XiyunApplication.class);
            String port = environment.getProperty("server.port", "8080");
            String contextPath = environment.getProperty("server.servlet.context-path", "");
            String baseUrl = "http://localhost:" + port + contextPath;
            String swaggerUrl = baseUrl + "/swagger-ui.html";
            String knife4jUrl = baseUrl + "/doc.html";
            log.info("应用启动成功 → {}", baseUrl);
            log.info("Swagger 文档地址 → {}", swaggerUrl);
            log.info("Knife4j 文档地址 → {}", knife4jUrl);
        };
    }
}
